package com.qumitech.visualnovel.controller.rest;

import com.google.common.collect.ImmutableMap;
import com.qumitech.visualnovel.model.common.BaseResponse;
import com.qumitech.visualnovel.model.common.BaseRsp;
import com.qumitech.visualnovel.model.common.ResultEnum;
import com.qumitech.visualnovel.model.dto.BookStatisticQueryDTO;
import com.qumitech.visualnovel.service.basic.RegisterChannelBasicStatisticsDataService;
import com.qumitech.visualnovel.service.basic.StartChannelBasicStatisticsDataService;
import com.qumitech.visualnovel.service.novel.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author :  ZhChNing
 * @Descriptiom :
 * @Date Created in 2019/3/12 17:31
 */

@RestController
@RequestMapping("/api/book")
public class BookController {
    @Autowired
    private BookService bookService;

    @GetMapping("/statistic/v2")
    public BaseRsp getBookStatisticList(@RequestParam(value = "start_time", required = false) String startTime,
                                        @RequestParam(value = "end_time", required = false) String endTime,
                                        @RequestParam(value = "geo_name", required = false) String geoName,
                                        @RequestParam(value = "channel", required = false) String channel,
                                        @RequestParam(value = "book_title", required = false) String bookTitle,
                                        @RequestParam(value = "book_ids", required = false) List<Integer> bookIds,
                                        @RequestParam(value = "offset", required = false, defaultValue = "0") Integer offset,
                                        @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit) {
        return new BaseRsp(ResultEnum.SUCCESS, bookService.getBookStatisticListV2(startTime, endTime, geoName, channel, bookTitle, bookIds, offset, limit));
    }

    @GetMapping("/chapter/statistic")
    public BaseRsp getChapterStatisticList(@RequestParam(value = "start_time", required = false) String startTime,
                                           @RequestParam(value = "end_time", required = false) String endTime,
                                           @RequestParam(value = "geo_name", required = false) String geoName,
                                           @RequestParam(value = "channel", required = false) String channel,
                                           @RequestParam(value = "book_title", required = false) String bookTitle,
                                           @RequestParam(value = "book_ids", required = false) List<Integer> bookIds,
                                           @RequestParam(value = "chapter_index", required = false) Integer chapterIndex,
                                           @RequestParam(value = "offset", required = false, defaultValue = "0") Integer offset,
                                           @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit) {
        return new BaseRsp(ResultEnum.SUCCESS, bookService.getChapterStatisticList(startTime, endTime, geoName, channel,
                bookTitle, bookIds, chapterIndex, offset, limit));
    }

    @GetMapping("/option/statistic")
    public BaseRsp getOptionStatisticList(@RequestParam(value = "start_time", required = false) String startTime,
                                          @RequestParam(value = "end_time", required = false) String endTime,
                                          @RequestParam(value = "geo_name", required = false) String geoName,
                                          @RequestParam(value = "channel", required = false) String channel,
                                          @RequestParam(value = "book_title", required = false) String bookTitle,
                                          @RequestParam(value = "book_ids", required = false) List<Integer> bookIds,
                                          @RequestParam(value = "chapter_index", required = false) Integer chapterIndex,
                                          @RequestParam(value = "offset", required = false, defaultValue = "0") Integer offset,
                                          @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit) {
        return new BaseRsp(ResultEnum.SUCCESS, bookService.getOptionStatisticList(startTime, endTime, geoName, channel,
                bookTitle, bookIds, chapterIndex, offset, limit));
    }




}
